package com.jiufen.Mapper;


import com.jiufen.Pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {

    /**
     * 查询所有部门
     *
     * @return
     */
  /*  @Results({
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime")
    })*/
    @Select("select id, name, create_time, update_time from dept order by update_time desc;")
    public List<Dept> queryDeptAll();

    /**
     * 根据id删除部门
     * @param id
     * @return
     */
    @Delete("delete from dept where id = #{id}")
    public Integer deleteById(Integer id);


    /**
     * 添加部门
     * @param dept
     * @return
     */
    @Insert("insert into dept(name,update_time,create_time) values(#{name},#{updateTime},#{createTime})")
    public Integer addDept(Dept dept);

    /**
     *
     * 根据id查询部门
     * @param id
     * @return
     */
    @Select("select id, name, create_time, update_time from dept where id = #{id} ")
    public Dept queryByDeptId(Integer id);

    /**
     * 根据ID修改部门信息
     * @param dept
     * @return
     */
    @Update("UPDATE dept set dept.`name`  = #{name},dept.update_time = #{updateTime} where  dept.id = #{id};")
    public Integer updateDeptById(Dept dept);

    @Select("select count(*) from emp where dept_id  = #{id}")
    Integer queryNumberPeople(Integer id);
}
